
#include "main.h"
//#include "Com_Cfg.h"

#define	INIT_REST	0
#define	INIT_STS	1
#define	DIAG_STS	2
#define	RUN_STS		3
#define	SLEEP_STS	4


#define	STEP_0		0
#define	STEP_1		1
#define	STEP_2		2
#define	STEP_3		3
#define	STEP_4		4
#define	STEP_5		5


u16	APPL_VB_U;
u8 testVBL;
u8 testVBH;
extern u16 data632[8];

#pragma anon_unions
u16 G_u16_Asw_CellFlg = 0;
u8 BMSL_FANCotrolHWDrvFault_Status = 0;

typedef union {
	u8  Bms_Sts_Num;                /*BMS运行状态值*/
    struct {
		u8 BSW_BCC_Flg            :1; /*BCC运行标志*/
		u8 BSW_AD_Flg         		:1; /*AD预准备标志*/
		u8 BSW_EEPROM_Flg         :1; /*EE诊断标志*/
		u8 BSW_RTC_Flg           	:1; /*RTC诊断标志*/
		u8 BSW_ER_Flg           	:1; /*ER_INIT标志*/
		u8 BSW_KL15_Flg           :1; /*KL15_INIT标志*/
    };
} APP_BMS_STS;
APP_BMS_STS App_Bms_StsFlg = {0x00};
u8 G_u8_APP_RUN_Flg = 0;

typedef union {
	u8  App_Sleep_Num;                		/*APP休眠标志*/
    struct {
		u8 APP_BCC_SLEEP_Flg       			:1; /*BCC休眠标志*/
		u8 APP_EE_SLEEP_Flg           	:1; /*EE休眠标志*/
		u8 APP_RTC_SLEEP_Flg           	:1; /*RTC休眠标志*/
    };
} APP_SLEEP_STS;
APP_SLEEP_STS App_Bms_Slp_Flg = {0x00};


/*********************APP-ADC*************************/
u16 G_u16_BMS_AD_Arr[10];
float f_HSIDE_A_Val;		/*继电器回采检测  ADC1_CH10*/
float f_KL30_Val;			/*MUX_OUT	ADC0_CH5*/
float f_AD_REF_Val;			/*SAFE-3.3	ADC0_CH1*/
float f_RELAY_Val;			/*RELAY+	ADC0_CH3*/


void APPL_BMS_ADC(void)
{
	ECU_ADC_GET_VALUE(G_u16_BMS_AD_Arr);

	f_HSIDE_A_Val = G_u16_BMS_AD_Arr[2];
	f_HSIDE_A_Val = f_HSIDE_A_Val * 12/4095;

	f_KL30_Val = G_u16_BMS_AD_Arr[7];
	BSW_12V_SupplyPowerVoltage = f_KL30_Val * 22.25/4095;/*大约为采集值的6,9倍 稍微小点  6.9*3.3=22.77 修正一下 22.25*/

	f_AD_REF_Val = G_u16_BMS_AD_Arr[1];
	f_AD_REF_Val = f_AD_REF_Val * 6.6/4095;

	f_RELAY_Val = G_u16_BMS_AD_Arr[5];
	f_RELAY_Val = f_RELAY_Val * 0.0088645 - 0.257;


	App_Bms_StsFlg.BSW_AD_Flg = true;
}


/*****************APP-KL15******************/

void APPL_BMS_KL15(void)
{
	u16 G_u16_IOstate;
	G_u16_IOstate=SBC4500_Read_Command(SBC_IO_INPUT);

	if((G_u16_IOstate & 0x0001)==0x0001)
	{
		BSW_Ign_State =	1;
	}
	else if((G_u16_IOstate&0x0001)==0)
	{
		BSW_Ign_State =0;
	}

	App_Bms_StsFlg.BSW_KL15_Flg = true;
}

/**********************APP-RELAY*************************/

/********************************
**函数：	APPL_BMS_RELAY
**功能：	根据应用层指令控制继电器状态
**输入：	无
**输出：	无
**注意：	继电器驱动线圈短路保护未加入
*********************************/

u8 u8_Relay_Debug = 0;
void APPL_BMS_RELAY(void)
{
	if(u8_Relay_Debug)
	{
		ECU_RELAY_OPEN();
	}
	else
	{
		ECU_RELAY_CLOSE();
	}

}

/********一直发送 直到SBC休眠断电********/
inline void APPL_BMS_CAN(void)
{
	if(G_u8_APP_RUN_Flg)
	{
//		CanApp();	/*632us*/
	}
}

u8 G_u8_Dtc_RW_Flg = 0;
u8 G_u8_Dtc_Len = 5;
u16 G_u16_Dtc_Add = 0;
	u32  G_u32_DataAddr = 0x0000D2F0;



extern const MC33771_CMD_FLG Mc33771_VCT[30];
u8 G_u8_DtcData[100];
/******************APP-MC33771**********************/
void APPL_BMS_MC33771(void)
{
	u8 u8_Status = 0;
	static u16 S_u8_Count = 0;
	u8 Appl_BCC_Err_Flg = false;
	static u8 u8_App_FAE_Step = INIT_REST;
	switch(u8_App_FAE_Step)
	{
		case INIT_REST:
		{
			App_Bms_StsFlg.BSW_BCC_Flg = false;
			u8_Status = ECU_MC33771_REST();
			if(u8_Status)
			{
				u8_App_FAE_Step = INIT_STS;
			}
			break;
		}
		case INIT_STS:
		{
			ECU_MC33771_INIT();
			u8_App_FAE_Step = DIAG_STS;
			break;
		}
		case DIAG_STS:  
		{
			u8_Status = APPL_MC33771_DIAG();
			if(u8_Status)
			{
				u8_App_FAE_Step = RUN_STS;
			}
			break;
		}
		case RUN_STS:
		{
			App_Bms_StsFlg.BSW_BCC_Flg = true;
			APPL_MC33771_RUN();
//			if(S_u8_Count > 500)
//			{
//				u8_App_FAE_Step = SLEEP_STS;
//				S_u8_Count =0;
//			}
//			else
//			{
//				S_u8_Count ++;
//			}
			if(ASW_SleepCmd)
			{
				u8_App_FAE_Step = SLEEP_STS;
			}
			else
			{
				Appl_BCC_Err_Flg = ECU_MC33771_ERR_Check();
				if(Appl_BCC_Err_Flg)
				{
					u8_App_FAE_Step = INIT_REST;
				}
			}
			break;
		}
		case SLEEP_STS:
		{
			if(App_Bms_Slp_Flg.APP_BCC_SLEEP_Flg == false)
			{
				if(S_u8_Count > 1)
				{
					App_Bms_Slp_Flg.APP_BCC_SLEEP_Flg = true;
				}
				else
				{
					APPL_MC33771_Clear_FLT();
					S_u8_Count ++;
				}
			}
			else
			{
				if(!ASW_SleepCmd)
				{
					S_u8_Count = 0;
					App_Bms_Slp_Flg.APP_BCC_SLEEP_Flg = false;
					App_Bms_StsFlg.BSW_BCC_Flg = false;
					u8_App_FAE_Step = INIT_REST;
				}
			}
			break;
		}
		default:
		{
			u8_App_FAE_Step = INIT_REST;
			break;
		}

	}
}

/*********************APP-EEPROM-RTC*********************/
u8 G_u8_ER_INIT_Step = STEP_0;
float G_f_RTC_Count = 0;
u32 G_u32_RTC_Count = 0;
u8 G_u8_SOC_Store_Flg = false;
u8 G_u8_DTC_Store_Flg = false;
u8 G_u8_DTC_RD_Flg = false;


u8 G_u8_App_ER_Step = STEP_0;
u8 S_u8_App_WFlg = 0;

u8 Dtc_Err_RDataArr[55] = {1,2,3,4,5,6,7,8,9,0,11,12,13};

void APPL_BMS_ER_INIT(void)
{
	u8 u8_Status = false;
	switch(G_u8_ER_INIT_Step)
	{
		case STEP_0:	/*读取RTC时钟的时间*/
		{
			G_u32_RTC_Count=SBC4500_Read_RTC();   /*读取RTC值*/
			BSW_Relativetime = G_u32_RTC_Count;
			BSW_Relativetime = BSW_Relativetime/ 3600;
			G_u8_ER_INIT_Step = STEP_1;
			break;
		}
		case STEP_1:
		{
			ECU_EEPROM_UDS_RCMD(); /*读取EEPROM中UDS标定的内容*/
			ECU_EEPROM_APP_RCMD(); /*读取EEPROM中的内容*/
			G_u8_ER_INIT_Step = STEP_2;
			break;
		}
		case STEP_2:
		{
			u8_Status = ECU_EEPROM_IDEL_Check();
			if(u8_Status)
			{
				ECU_EE_RDtcErrFlg((u32)Dtc_Err_RDataArr,55,0);
				G_u8_ER_INIT_Step = STEP_3;
			}
			break;
		}
		case STEP_3:
		{
			u8_Status = ECU_EEPROM_IDEL_Check();
			if(u8_Status)
			{
				ECU_EEPROM_Clear_12V_Flg();
				G_u8_ER_INIT_Step = STEP_4;
			}
			break;
		}
		case STEP_4:
		{
			G_u8_ER_INIT_Step = STEP_0;
			ECU_EEPROM_PRT();
			App_Bms_StsFlg.BSW_ER_Flg = true;
			App_Bms_StsFlg.BSW_EEPROM_Flg = true;
			App_Bms_StsFlg.BSW_RTC_Flg = true;
			break;
		}
		default:
		{
			G_u8_ER_INIT_Step = STEP_0;
			break;
		}
	}
}

void APPL_BMS_DOFLG(void)
{
	if(ASW_SOC_StoreCmd)			/*APP运行完就要对这个变量进行判定*/
	{
		ECU_EEPROM_APP_WCMD();
		ASW_SOC_StoreCmd = 0;
	}
}

void APPL_BMS_ER_NRL_SLP(void)
{
	u8 u8_Staus = 0;
	switch(G_u8_App_ER_Step)
	{
		case STEP_0:
		{
			u8_Staus = ECU_EEPROM_IDEL_Check();
			if(u8_Staus)
			{
				if(ASW_SleepCmd)
				{
					S_u8_App_WFlg = 1;
					G_u8_App_ER_Step = STEP_1;
				}
			}
			break;
		}
		case STEP_1:
		{
			ECU_EEPROM_APP_WCMD();
			G_u8_App_ER_Step = STEP_2;
			break;
		}
		case STEP_2:
		{
			u8_Staus = ECU_EEPROM_IDEL_Check();
			if(u8_Staus)
			{
				App_Bms_Slp_Flg.APP_EE_SLEEP_Flg = true;
				G_u8_App_ER_Step = STEP_3;
			}
			break;
		}
		case STEP_3:
		{
			if(App_Bms_Slp_Flg.APP_RTC_SLEEP_Flg == false)
			{
				SBC4500_Start_RTC();   /*清除RTC值并开启*/
				App_Bms_Slp_Flg.APP_RTC_SLEEP_Flg = true;
			}
			G_u8_App_ER_Step = STEP_4;
			break;
		}
		case STEP_4:
		{
			if(!ASW_SleepCmd)
			{
				/*******清除状态标志*******/
				App_Bms_StsFlg.BSW_ER_Flg = false;
				App_Bms_StsFlg.BSW_EEPROM_Flg = false;
				App_Bms_StsFlg.BSW_RTC_Flg = false;
				/*******清除休眠标志*******/
				App_Bms_Slp_Flg.APP_EE_SLEEP_Flg = false;
				App_Bms_Slp_Flg.APP_RTC_SLEEP_Flg = false;
				G_u8_App_ER_Step = STEP_0;
			}
			break;
		}
		default:
		{
			G_u8_App_ER_Step = STEP_0;
			break;
		}
	}
}

void APPL_BMS_EE_RTC_RUN(void)
{
	if(!App_Bms_StsFlg.BSW_ER_Flg)
	{
		APPL_BMS_ER_INIT();
	}
	else
	{
		APPL_BMS_ER_NRL_SLP();
	}
	ECU_EEPROM_RUN();
}







/******************************/
void APPL_BMS_SLEEP(void)
{
	if(App_Bms_Slp_Flg.App_Sleep_Num == 0x07)
	{
		SBC4500_Go_Sleep();   /*SBC进入休眠，MCU断电*/
	}
	else
	{

	}
}


/*****************APP-RUN*****************/
void APPL_BMS_RUNFLG(void)
{
	if(App_Bms_StsFlg.Bms_Sts_Num == 0x3F)
	{
		G_u8_APP_RUN_Flg = true;
	}
}

void APPL_BMS_RUNAPP(void)
{

	APPL_BMS_RUNFLG();

	if(G_u8_APP_RUN_Flg)
	{
		ASWC_step();
	}
	APPL_BMS_DOFLG();
}


u16 DCDC_UHV_M;
u16 DCDC_IHV_M;
u16 BSGL_SCU_Bus_Voltage_M;
u16 BSGL_SCU_IDC_Current_M;
uint8 FANtest;
u8 EMS_HCU_CrashOutputSts_M;

/******************************************************
DCDC_UHV	高压端检测到的电压
DCDC_IHV	高压端能提供或索取的电流
BSGL_SCU_Bus_Voltage	48V端电压
BSGL_SCU_IDC_Current	直流电流
EMS_HCU_InsideTemperature	车内温度传感器读数
EMS_HCU_InsideTemperatureInvalid	车内温度传感器合法标记
EMS_HCU_veh_cb_cmd_e	HCU发出关闭继电器的请求
EMS_EngineSpeedRPMInvalid	EMS引擎转速非法信号
EMS_EngStatus	发动机状态信息
EMS_HCU_CrashOutputSts_bit1	bit1:Front First Level
EMS_HCU_CrashOutputSts_bit2	bit2:Left Hand Side
EMS_HCU_CrashOutputSts_bit3	bit3:Right Hand Side
EMS_HCU_CrashOutputSts_bit4	指示碰撞输出状态
EMS_EngineSpeedRPM	EMS信号提示引擎转速
EMS_IPK_TotalOdometer	仪表显示的总里程
*****************************************************/

/***************************************************************
Diag_CAN_BusOff_Flg							CAN总线关闭标志位
Diag_EMS_MsgMissing_Flg						EMS报文丢失
Diag_InnerCommunicationFlt_Flg				内部通讯故障
Diag_TempSamplingShortGND_Flg				电池包温度采样电流短路到地
Diag_TempSamplingShortPWR_Flg				电池包温度采样电流短路到电源
Diag_OverCurrHW_Flg							电池包过流硬件故障
Diag_CellHW_Flg								电池单体电压过高硬件故障
Diag_CellSamplingOpen_Flg					电池单体电压采样电路开路
Diag_StackUlSamplingOpen_Flg				总电压采样电路开路
Diag_TermUSamplingShortGND_Flg				48V回路电压采样电路短地
Diag_TermUSamplingShortPWR_Flg				48V回路电压采样电路短电源
Diag_CurrSamplingShortGND_Flg				电流采样电路短路到地
Diag_CurrSamplingOpen_Flg					电流采样电路开路
Diag_SW5V_FLT_Flg	5V						回路故障
Diag_FAN_Fault_Flg							风扇故障
Diag_Cell_BAL_SW_Flg						均衡回路故障
Diag_BCC_Mismatch_Flg						BCC芯片故障
Diag_VSUP_HW_OVP_MON_Flg					过压保护硬件电路故障
Diag_HW_OverTempProtection_Flg				硬件过温保护
Diag_MemoryFlt_Flg							BMS内存故障
Diag_FAN_HWDrvFlt_Flg						风扇硬件驱动故障
**************************************************************/
extern float BSW_BattBalanTmp;
u8 G_u8_BattBalanTmp;
extern u32 G_u32_WR_Count;
extern float G_f_EER_Count;
u8 G_u8_Curr_p;

void APPL_BMS_Recive(void)
{
	/**************************************
	uint8 EMS_HCU_InsideTemperature_M;
	bool EMS_HCU_InsideTemperatureInvalid_M;
	bool ;
	bool EMS_EngineSpeedRPMInvalid_M;
	uint8 EMS_EngStatus_M;
	uint8 ;
	uint16 EMS_EngineSpeedRPM_M;
	uint32 EMS_IPK_TotalOdometer_M;
	***************************************/
//	Com_ReceiveSignal(COM_RXSIGDCDC_UHV,&DCDC_UHV_M);
//	Com_ReceiveSignal(COM_RXSIGDCDC_IHV,&DCDC_IHV_M);
//	Com_ReceiveSignal(COM_RXSIGBSGL_SCU_BUS_VOLTAGE,&BSGL_SCU_Bus_Voltage_M);
//	Com_ReceiveSignal(COM_RXSIGBSGL_SCU_IDC_CURRENT,&BSGL_SCU_IDC_Current_M);
//	Com_ReceiveSignal(COM_RXSIGEMS_HCU_VEH_CB_CMD_E,&EMS_HCU_veh_cb_cmd_e);
//	Com_ReceiveSignal(COM_RXSIGEMS_HCU_CRASHOUTPUTSTS,&EMS_HCU_CrashOutputSts_M);

//	DCDC_IHV=(s16)DCDC_IHV_M-255;
//	BSGL_SCU_Bus_Voltage=(single)BSGL_SCU_Bus_Voltage_M*0.02;

//	EMS_HCU_CrashOutputSts_bit1=(boolean)(EMS_HCU_CrashOutputSts_M>>1);
//	EMS_HCU_CrashOutputSts_bit2=(boolean)(EMS_HCU_CrashOutputSts_M>>2);
//	EMS_HCU_CrashOutputSts_bit3=(boolean)(EMS_HCU_CrashOutputSts_M>>3);
//	EMS_HCU_CrashOutputSts_bit4=(boolean)(EMS_HCU_CrashOutputSts_M>>4);

//	testVBH= (u8)(APPL_VB_U>>8);
//	testVBL= (u8)(APPL_VB_U);


//	G_u8_BattBalanTmp = 40+BSW_BattBalanTmp;
//	G_u8_Curr_p =  G_f_EER_Count;
//	data632[6] = (G_u16_Asw_CellFlg >> 8);
//	data632[7] = (G_u16_Asw_CellFlg & 0xFF);


//	Com_SendSignal(	COM_TXSIGTX632_BYTE0 	,	&testVBH	);				/*	1号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGTX632_BYTE1 	,	&testVBL	);				/*	1号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGTX632_BYTE2 	,	&Diag_FAN_Fault_Flg);
//	Com_SendSignal(	COM_TXSIGTX632_BYTE3 	,	&FANtest	);
//	Com_SendSignal(	COM_TXSIGTX632_BYTE4 	,	&G_u8_Curr_p	);			/*	1号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGTX632_BYTE5 	,	&G_u8_BattBalanTmp);
//	Com_SendSignal(	COM_TXSIGTX632_BYTE6 	,	&data632[6]	);
//	Com_SendSignal(	COM_TXSIGTX632_BYTE7	,	&data632[7]);

}

u16	APPL_BMSL_cell_01_U;
u16	APPL_BMSL_cell_02_U;
u16	APPL_BMSL_cell_03_U;
u16	APPL_BMSL_cell_04_U;
u16	APPL_BMSL_cell_05_U;
u16	APPL_BMSL_cell_06_U;
u16	APPL_BMSL_cell_07_U;
u16	APPL_BMSL_cell_08_U;
u16	APPL_BMSL_cell_09_U;
u16	APPL_BMSL_cell_10_U;
u16	APPL_BMSL_cell_11_U;
u16	APPL_BMSL_cell_12_U;
u16	APPL_BMSL_cell_13_U;
u16	APPL_BMSL_max_cell_U;
u16	APPL_BMSL_min_cell_U;
u16	APPL_BMSL_stack_U;
u16	APPL_BMSL_term_U;
u16	APPL_BMSL_lv_pwr_U;

u8	APPL_BMSL_cell_01_bal_actv_b;
u8	APPL_BMSL_cell_02_bal_actv_b;
u8	APPL_BMSL_cell_03_bal_actv_b;
u8	APPL_BMSL_cell_04_bal_actv_b;
u8	APPL_BMSL_cell_05_bal_actv_b;
u8	APPL_BMSL_cell_06_bal_actv_b;
u8	APPL_BMSL_cell_07_bal_actv_b;
u8	APPL_BMSL_cell_08_bal_actv_b;
u8	APPL_BMSL_cell_09_bal_actv_b;
u8	APPL_BMSL_cell_10_bal_actv_b;
u8	APPL_BMSL_cell_11_bal_actv_b;
u8	APPL_BMSL_cell_12_bal_actv_b;
u8	APPL_BMSL_cell_13_bal_actv_b;

u8	APPL_BMSL_ign_b;
u8	APPL_BMSL_hw_ovp_actv_b;
u8	APPL_BMSL_pwrmon_b;
u8	APPL_BMSL_termU_samp_pwr_actv_b;
u8	APPL_BMSL_cb_stuck_open_actv_b;
u8	APPL_BMSL_equalize_fail_actv_b;
u8	APPL_BMSL_cb_weld_actv_b;
u8	APPL_BMSL_pwr_ovp_actv_b;
u8	APPL_BMSL_pwr_uvp_actv_b;
u8	APPL_BMSL_cell_ovp_actv_b;
u8	APPL_BMSL_cell_uvp_actv_b;
u8	APPL_BMSL_pack_ovp_actv_b;
u8	APPL_BMSL_pack_uvp_actv_b;
u8	APPL_BMSL_temp_fault_actv_b;
u8	APPL_BMSL_ocp_actv_b;
u8	APPL_BMSL_bcc_comm_fault_actv_b;
u8	APPL_BMSL_bcc_fault_actv_b;
u8	APPL_BMSL_ecu_comm_fault_actv_b;
u8	APPL_BMSL_current_samp_invalid_actv_b;
u8	APPL_BMSL_current_samp_open_actv_b;
u8	APPL_BMSL_current_samp_gnd_actv_b;
u8	APPL_BMSL_termU_samp_invalid_actv_b;
u8	APPL_BMSL_cbal_en_b;
u8	APPL_BMSL_termU_samp_gnd_actv_b;
u8	APPL_BMSL_stackU_samp_invalid_actv_b;
u8	APPL_BMSL_stackU_samp_open_actv_b;
u8	APPL_BMSL_cell_samp_invalid_actv_b;
u8	APPL_BMSL_cell_samp_open_actv_b;
u8	APPL_BMSL_temp_samp_gnd_actv_b;
u8	APPL_BMSL_temp_samp_pwr_actv_b;
u8	APPL_BMSL_temp_samp_invalid_actv_b;
u8	APPL_BMSL_cell_U_samplingfault_actv_b;
u8	APPL_BMSL_inst_I_samplingfault_actv_b;


s32	APPL_BMSL_inst_I;
u16	APPL_BMSL_pack_1_T;
u16	APPL_BMSL_pack_2_T;

u16	APPL_BMSL_pack_soc_abs_Pct;
u16	APPL_BMSL_PACK_STATUS_1_AliveCounter;
u16	APPL_BMSL_cb_state_e;
u16	APPL_BMSL_Fault_status;
u16	APPL_BMSL_pack_mode;
u16	APPL_BMSL_FAN_Control_PWM;
u16	APPL_BMSL_FAN_Fault_Status;
u16	APPL_BMSL_FANCotrolHWDrvFault_Status;
u16	APPL_BMSL_pack_soh;
u16	APPL_BMSL_avail_dschrg_1s_PKW;
u16	APPL_BMSL_avail_dschrg_1s_IA;
u16	APPL_BMSL_avail_chrg_1s_PKW;
u16	APPL_BMSL_avail_chrg_1s_IA;
u16	APPL_BMSL_avail_dschrg_10s_PKW;
u16	APPL_BMSL_avail_dschrg_10s_IA;
u16	APPL_BMSL_avail_chrg_10s_PKW;
u16	APPL_BMSL_avail_chrg_10s_IA;
u16	APPL_BMSL_avail_dschrg_60s_PKW;
u16	APPL_BMSL_avail_dschrg_60s_IA;
u16	APPL_BMSL_avail_chrg_60s_PKW;
u16	APPL_BMSL_avail_chrg_60s_IA;
u16	APPL_BMSL_cb_lifetime_remain_Pct;




void APPL_BMS_RUN_DTC(void)
{
#if 0
	APPL_BMSL_cell_01_bal_actv_b	=	(u16)(BMSL_cell_01_bal_actv_b);
	APPL_BMSL_cell_01_U	=	(u16)(BMSL_cell_01_U * 1000);
	APPL_BMSL_cell_02_bal_actv_b	=	(u16)(BMSL_cell_02_bal_actv_b);
	APPL_BMSL_cell_02_U	=	(u16)(BMSL_cell_02_U * 1000);
	APPL_BMSL_cell_03_bal_actv_b	=	(u16)(BMSL_cell_03_bal_actv_b);
	APPL_BMSL_cell_03_U	=	(u16)(BMSL_cell_03_U * 1000);
	APPL_BMSL_cell_04_bal_actv_b	=	(u16)(BMSL_cell_04_bal_actv_b);
	APPL_BMSL_cell_04_U	=	(u16)(BMSL_cell_04_U * 1000);
	APPL_BMSL_cell_05_bal_actv_b	=	(u16)(BMSL_cell_05_bal_actv_b);
	APPL_BMSL_cell_05_U	=	(u16)(BMSL_cell_05_U * 1000);
	APPL_BMSL_cell_06_bal_actv_b	=	(u16)(BMSL_cell_06_bal_actv_b);
	APPL_BMSL_cell_06_U	=	(u16)(BMSL_cell_06_U * 1000);
	APPL_BMSL_cell_07_bal_actv_b	=	(u16)(BMSL_cell_07_bal_actv_b);
	APPL_BMSL_cell_07_U	=	(u16)(BMSL_cell_07_U * 1000);
	APPL_BMSL_cell_08_bal_actv_b	=	(u16)(BMSL_cell_08_bal_actv_b);
	APPL_BMSL_cell_08_U	=	(u16)(BMSL_cell_08_U * 1000);
	APPL_BMSL_cell_09_bal_actv_b	=	(u16)(BMSL_cell_09_bal_actv_b);
	APPL_BMSL_cell_09_U	=	(u16)(BMSL_cell_09_U * 1000);
	APPL_BMSL_cell_10_bal_actv_b	=	(u16)(BMSL_cell_10_bal_actv_b);
	APPL_BMSL_cell_10_U	=	(u16)(BMSL_cell_10_U * 1000);
	APPL_BMSL_cell_11_bal_actv_b	=	(u16)(BMSL_cell_11_bal_actv_b);
	APPL_BMSL_cell_11_U	=	(u16)(BMSL_cell_11_U * 1000);
	APPL_BMSL_cell_12_bal_actv_b	=	(u16)(BMSL_cell_12_bal_actv_b);
	APPL_BMSL_cell_12_U	=	(u16)(BMSL_cell_12_U * 1000);
	APPL_BMSL_cell_13_bal_actv_b	=	(u16)(BMSL_cell_13_bal_actv_b);
	APPL_BMSL_cell_13_U	=	(u16)(BMSL_cell_13_U * 1000);

	APPL_BMSL_max_cell_U	=	(u16)(BMSL_max_cell_U * 1000);
	APPL_BMSL_min_cell_U	=	(u16)(BMSL_min_cell_U * 1000);
	APPL_BMSL_stack_U	=	(u16)(BMSL_stack_U * 1000);
	APPL_BMSL_term_U	=	(u16)(BMSL_term_U * 1000);


	APPL_BMSL_inst_I	=	(s32)(BMSL_inst_I * 1000);

	APPL_BMSL_pack_1_T	=	(u16)(BMSL_pack_1_T*10 + 400);
	APPL_BMSL_ign_b	=	(u16)(BMSL_ign_b);
	APPL_BMSL_hw_ovp_actv_b	=	(u16)(BMSL_hw_ovp_actv_b);
	APPL_BMSL_pack_2_T	=	(u16)(BMSL_pack_2_T*10 + 400);
	APPL_BMSL_pwrmon_b	=	(u16)(BMSL_pwrmon_b);
	APPL_BMSL_lv_pwr_U	=	(u16)(BMSL_lv_pwr_U*1000);
	APPL_BMSL_pack_soc_abs_Pct	=	(u16)(BMSL_pack_soc_abs_Pct);
	/*APPL_BMSL_PACK_STATUS_1_AliveCounter	=	(u16)(BMSL_PACK_STATUS_1_AliveCounter);*/
	APPL_BMSL_cb_state_e	=	(u16)(BMSL_cb_state_e);
//	APPL_BMSL_termU_samp_pwr_actv_b	=	(u16)(BMSL_termU_samp_pwr_actv_b);
	APPL_BMSL_Fault_status	=	(u16)(BMSL_Fault_status);
	APPL_BMSL_pack_mode	=	(u16)(BMSL_pack_mode);
	APPL_BMSL_cb_stuck_open_actv_b	=	(u16)(BMSL_cb_stuck_open_actv_b);
	APPL_BMSL_equalize_fail_actv_b	=	(u16)(BMSL_equalize_fail_actv_b);
	APPL_BMSL_cb_weld_actv_b	=	(u16)(BMSL_cb_weld_actv_b);
	APPL_BMSL_pwr_ovp_actv_b	=	(u16)(BMSL_pwr_ovp_actv_b);
	APPL_BMSL_pwr_uvp_actv_b	=	(u16)(BMSL_pwr_uvp_actv_b );
	APPL_BMSL_cell_ovp_actv_b	=	(u16)(BMSL_cell_ovp_actv_b);
	APPL_BMSL_cell_uvp_actv_b	=	(u16)(BMSL_cell_uvp_actv_b);
	APPL_BMSL_pack_ovp_actv_b	=	(u16)(BMSL_pack_ovp_actv_b);
	APPL_BMSL_pack_uvp_actv_b	=	(u16)(BMSL_pack_uvp_actv_b);
	APPL_BMSL_temp_fault_actv_b	=	(u16)(BMSL_temp_fault_actv_b);
	APPL_BMSL_ocp_actv_b	=	(u16)(BMSL_ocp_actv_b);
	APPL_BMSL_bcc_comm_fault_actv_b	=	(u16)(BMSL_bcc_comm_fault_actv_b);
	APPL_BMSL_bcc_fault_actv_b	=	(u16)(BMSL_bcc_fault_actv_b);
	APPL_BMSL_ecu_comm_fault_actv_b	=	(u16)(BMSL_ecu_comm_fault_actv_b);
	APPL_BMSL_current_samp_invalid_actv_b	=	(u16)(BMSL_current_samp_invalid_actv_b);
	APPL_BMSL_current_samp_open_actv_b	=	(u16)(BMSL_current_samp_open_actv_b);
	APPL_BMSL_current_samp_gnd_actv_b	=	(u16)(BMSL_current_samp_gnd_actv_b);
	APPL_BMSL_termU_samp_invalid_actv_b	=	(u16)(BMSL_termU_samp_invalid_actv_b);
//	APPL_BMSL_cbal_en_b	=	(u16)(BMSL_cbal_en_b);
	APPL_BMSL_termU_samp_gnd_actv_b	=	(u16)(BMSL_termU_samp_gnd_actv_b);
	APPL_BMSL_stackU_samp_invalid_actv_b	=	(u16)(BMSL_stackU_samp_invalid_actv_b);
	APPL_BMSL_stackU_samp_open_actv_b	=	(u16)(BMSL_stackU_samp_open_actv_b);
	APPL_BMSL_cell_samp_invalid_actv_b	=	(u16)(BMSL_cell_samp_invalid_actv_b);
	APPL_BMSL_cell_samp_open_actv_b	=	(u16)(BMSL_cell_samp_open_actv_b);
	APPL_BMSL_temp_samp_gnd_actv_b	=	(u16)(BMSL_temp_samp_gnd_actv_b);
	APPL_BMSL_temp_samp_pwr_actv_b	=	(u16)(BMSL_temp_samp_pwr_actv_b);
	APPL_BMSL_temp_samp_invalid_actv_b	=	(u16)(BMSL_temp_samp_invalid_actv_b);
	APPL_BMSL_cell_U_samplingfault_actv_b	=	(u16)(BMSL_cell_U_samplingfault_actv_b);
	APPL_BMSL_inst_I_samplingfault_actv_b	=	(u16)(BMSL_inst_I_samplingfault_actv_b);
	APPL_BMSL_FAN_Control_PWM	=	(u16)(BMSL_FAN_Control_PWM);
	APPL_BMSL_FAN_Fault_Status	=	(u16)(Diag_FAN_Fault_Flg * 3);
	APPL_BMSL_FANCotrolHWDrvFault_Status	=	(u16)(BMSL_FANCotrolHWDrvFault_Status);
	APPL_BMSL_pack_soh	=	(u16)(BMSL_pack_soh * 10);
	APPL_BMSL_avail_dschrg_1s_PKW	=	(u16)(BMSL_avail_dschrg_1s_PKW * 100 + 4094);
	APPL_BMSL_avail_dschrg_1s_IA	=	(u16)(BMSL_avail_dschrg_1s_IA + 1022);
	APPL_BMSL_avail_chrg_1s_PKW	=	(u16)(BMSL_avail_chrg_1s_PKW * 100);
	APPL_BMSL_avail_chrg_1s_IA	=	(u16)(BMSL_avail_chrg_1s_IA);
	APPL_BMSL_avail_dschrg_10s_PKW	=	(u16)(BMSL_avail_dschrg_10s_PKW * 100 + 4094);
	APPL_BMSL_avail_dschrg_10s_IA	=	(u16)(BMSL_avail_dschrg_10s_IA + 1022);
	APPL_BMSL_avail_chrg_10s_PKW	=	(u16)(BMSL_avail_chrg_10s_PKW * 100);
	APPL_BMSL_avail_chrg_10s_IA	=	(u16)(BMSL_avail_chrg_10s_IA);
	APPL_BMSL_avail_dschrg_60s_PKW	=	(u16)(BMSL_avail_dschrg_60s_PKW * 100 + 4094);
	APPL_BMSL_avail_dschrg_60s_IA	=	(u16)(BMSL_avail_dschrg_60s_IA + 1022);
	APPL_BMSL_avail_chrg_60s_PKW	=	(u16)(BMSL_avail_chrg_60s_PKW * 100);
	APPL_BMSL_avail_chrg_60s_IA	=	(u16)(BMSL_avail_chrg_60s_IA);
	APPL_BMSL_cb_lifetime_remain_Pct	=	(u16)BMSL_cb_lifetime_remain_Pct;
#endif
}

void APPL_BMS_SEND_DTC(void)
{
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_01_BAL_ACTV_B 	,	&APPL_BMSL_cell_01_bal_actv_b	);/*	1号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_01_U  	,	&APPL_BMSL_cell_01_U	);/*	1号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_02_BAL_ACTV_B	,	&APPL_BMSL_cell_02_bal_actv_b	);/*	2号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_02_U	,	&APPL_BMSL_cell_02_U	);/*	2号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_03_BAL_ACTV_B	,	&APPL_BMSL_cell_03_bal_actv_b	);/*	3号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_03_U	,	&APPL_BMSL_cell_03_U	);/*	3号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_04_BAL_ACTV_B	,	&APPL_BMSL_cell_04_bal_actv_b	);/*	4号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_04_U	,	&APPL_BMSL_cell_04_U	);/*	4号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_05_BAL_ACTV_B 	,	&APPL_BMSL_cell_05_bal_actv_b	);/*	5号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_05_U	,	&APPL_BMSL_cell_05_U	);/*	5号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_06_BAL_ACTV_B	,	&APPL_BMSL_cell_06_bal_actv_b	);/*	6号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_06_U 	,	&APPL_BMSL_cell_06_U	);/*	6号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_07_BAL_ACTV_B	,	&APPL_BMSL_cell_07_bal_actv_b	);/*	7号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_07_U	,	&APPL_BMSL_cell_07_U	);/*	7号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_08_BAL_ACTV_B	,	&APPL_BMSL_cell_08_bal_actv_b	);/*	8号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_08_U	,	&APPL_BMSL_cell_08_U	);/*	8号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_09_BAL_ACTV_B	,	&APPL_BMSL_cell_09_bal_actv_b	);/*	9号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_09_U	,	&APPL_BMSL_cell_09_U	);/*	9号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_10_BAL_ACTV_B	,	&APPL_BMSL_cell_10_bal_actv_b	);/*	10号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_10_U	,	&APPL_BMSL_cell_10_U	);/*	10号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_11_BAL_ACTV_B 	,	&APPL_BMSL_cell_11_bal_actv_b	);/*	11号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_11_U 	,	&APPL_BMSL_cell_11_U	);/*	11号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_12_BAL_ACTV_B	,	&APPL_BMSL_cell_12_bal_actv_b	);/*	12号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_12_U 	,	&APPL_BMSL_cell_12_U	);/*	12号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_13_BAL_ACTV_B	,	&APPL_BMSL_cell_13_bal_actv_b	);/*	13号电芯均衡开启状态标志位	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_13_U 	,	&APPL_BMSL_cell_13_U	);/*	13号单体电芯电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_MAX_CELL_U 	,	&APPL_BMSL_max_cell_U	);/*	单体最大电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_MIN_CELL_U	,	&APPL_BMSL_min_cell_U	);/*	单体最小电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_STACK_U	,	&APPL_BMSL_stack_U	);/*	电池包总电压(电池包继电器内侧)	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TERM_U	,	&APPL_BMSL_term_U	);/*	48V回路电压(电池包继电器外侧)	*/
//	Com_SendSignal(	COM_TXSIGBMSL_INST_I 	,	&APPL_BMSL_inst_I	);/*	电池包电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_1_T	,	&APPL_BMSL_pack_1_T	);/*	1号温度传感器值	*/
//	Com_SendSignal(	COM_TXSIGBMSL_IGN_B 	,	&APPL_BMSL_ign_b	);/*	点火信号输入状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_HW_OVP_ACTV_B	,	&APPL_BMSL_hw_ovp_actv_b	);/*	单体硬件过压故障标志	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_2_T 	,	&APPL_BMSL_pack_2_T	);/*	2号温度传感器值	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PWRMON_B	,	&APPL_BMSL_pwrmon_b	);/*	继电器控制线圈电压监控正常	*/
//	Com_SendSignal(	COM_TXSIGBMSL_LV_PWR_U	,	&APPL_BMSL_lv_pwr_U	);/*	12V电源电压采样值	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_SOC_ABS_PCT	,	&APPL_BMSL_pack_soc_abs_Pct	);/*	电池SOC	*/
//	/*Com_SendSignal(	COM_TXSIGBMSL_PACK_STATUS_1_ALIVECOUNTER	,	&APPL_BMSL_PACK_STATUS_1_AliveCounter	);*//*	消息计算器	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CB_STATE_E	,	&APPL_BMSL_cb_state_e	);/*	电池包内继电器状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TERMU_SAMP_PWR_ACTV_B	,	&APPL_BMSL_termU_samp_pwr_actv_b	);/*	48V回路电压采样电路短电源故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_FAULT_STATUS 	,	&APPL_BMSL_Fault_status	);/*	BMSL故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_MODE	,	&APPL_BMSL_pack_mode	);/*	48V电池的运行模式	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CB_STUCK_OPEN_ACTV_B 	,	&APPL_BMSL_cb_stuck_open_actv_b	);/*	继电器粘连到断开	*/
//	Com_SendSignal(	COM_TXSIGBMSL_EQUALIZE_FAIL_ACTV_B	,	&APPL_BMSL_equalize_fail_actv_b	);/*	预充失败	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CB_WELD_ACTV_B	,	&APPL_BMSL_cb_weld_actv_b	);/*	继电器粘连到闭合	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PWR_OVP_ACTV_B	,	&APPL_BMSL_pwr_ovp_actv_b	);/*	12V供电电压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PWR_UVP_ACTV_B	,	&APPL_BMSL_pwr_uvp_actv_b	);/*	12V供电欠压	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_OVP_ACTV_B	,	&APPL_BMSL_cell_ovp_actv_b	);/*	电池单体过压故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_UVP_ACTV_B 	,	&APPL_BMSL_cell_uvp_actv_b	);/*	电池单体欠压故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_OVP_ACTV_B 	,	&APPL_BMSL_pack_ovp_actv_b	);/*	电池包总电压过压故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_UVP_ACTV_B 	,	&APPL_BMSL_pack_uvp_actv_b	);/*	电池包总电压欠压故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TEMP_FAULT_ACTV_B 	,	&APPL_BMSL_temp_fault_actv_b	);/*	电池包温度异常故障	*/
//	Com_SendSignal(	COM_TXSIGBMSL_OCP_ACTV_B	,	&APPL_BMSL_ocp_actv_b	);/*	充放电电流过大故障	*/
//	Com_SendSignal(	COM_TXSIGBMSL_BCC_COMM_FAULT_ACTV_B	,	&APPL_BMSL_bcc_comm_fault_actv_b	);/*	BCC(单体采样芯片)通信故障	*/
//	Com_SendSignal(	COM_TXSIGBMSL_BCC_FAULT_ACTV_B	,	&APPL_BMSL_bcc_fault_actv_b	);/*	BCC(单体采样芯片)故障	*/
//	Com_SendSignal(	COM_TXSIGBMSL_ECU_COMM_FAULT_ACTV_B	,	&APPL_BMSL_ecu_comm_fault_actv_b	);/*	BMS接收ECU报文通信超时	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CURRENT_SAMP_INVALID_ACTV_B	,	&APPL_BMSL_current_samp_invalid_actv_b	);/*	电流采样超范围故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CURRENT_SAMP_OPEN_ACTV_B 	,	&APPL_BMSL_current_samp_open_actv_b	);/*	电流采样电路开路故障	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CURRENT_SAMP_GND_ACTV_B  	,	&APPL_BMSL_current_samp_gnd_actv_b	);/*	电流采样电路短地故障状态	*/
////	Com_SendSignal(		,	&APPL_BMSL_termU_samp_invalid_actv_b	);/*	48V回路电压采样超范围故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CBAL_EN_B	,	&APPL_BMSL_cbal_en_b	);/*	电池均衡启动状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TERMU_SAMP_GND_ACTV_B	,	&APPL_BMSL_termU_samp_gnd_actv_b	);/*	48V回路电压采样电路短地故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TERMU_SAMP_INVALID_ACTV_B	,	&APPL_BMSL_stackU_samp_invalid_actv_b	);/*	电池包总压采样超范围故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_STACKU_SAMP_OPEN_ACTV_B	,	&APPL_BMSL_stackU_samp_open_actv_b	);/*	电池包总压采样电路开路故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_SAMP_INVALID_ACTV_B	,	&APPL_BMSL_cell_samp_invalid_actv_b	);/*	单体电压采样超范围故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CELL_SAMP_OPEN_ACTV_B	,	&APPL_BMSL_cell_samp_open_actv_b	);/*	单体电压采样电路开路故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TEMP_SAMP_GND_ACTV_B	,	&APPL_BMSL_temp_samp_gnd_actv_b	);/*	温度采样电路短地故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TEMP_SAMP_PWR_ACTV_B	,	&APPL_BMSL_temp_samp_pwr_actv_b	);/*	温度采样电路短电源故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_TEMP_SAMP_INVALID_ACTV_B	,	&APPL_BMSL_temp_samp_invalid_actv_b	);/*	温度采样超范围故障状态	*/
////	Com_SendSignal(		,	&APPL_BMSL_cell_U_samplingfault_actv_b	);/*	单体电压采样故障	*/
////	Com_SendSignal(		,	&APPL_BMSL_inst_I_samplingfault_actv_b	);/*	电流采样故障	*/
//	Com_SendSignal(	COM_TXSIGBMSL_FAN_CONTROL_PWM	,	&APPL_BMSL_FAN_Control_PWM	);/*	BMS输出的风扇控制PWM信号占空比	*/
//	Com_SendSignal(	COM_TXSIGBMSL_FAN_FAULT_STATUS	,	&APPL_BMSL_FAN_Fault_Status	);/*	散热风扇故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_FANCOTROLHWDRVFAULT_STATUS	,	&APPL_BMSL_FANCotrolHWDrvFault_Status	);/*	BMS PWM控制硬件驱动电路故障状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_PACK_SOH	,	&APPL_BMSL_pack_soh	);/*	电池包健康状态	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_DSCHRG_1S_PKW	,	&APPL_BMSL_avail_dschrg_1s_PKW	);/*	1s内最大放电功率	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_DSCHRG_1S_IA	,	&APPL_BMSL_avail_dschrg_1s_IA	);/*	1s内最大放电电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_CHRG_1S_PKW	,	&APPL_BMSL_avail_chrg_1s_PKW	);/*	1s内最大充电功率	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_CHRG_1S_IA	,	&APPL_BMSL_avail_chrg_1s_IA	);/*	1s内最大充电电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_DSCHRG_10S_PKW	,	&APPL_BMSL_avail_dschrg_10s_PKW	);/*	10s内最大放电功率	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_DSCHRG_10S_IA	,	&APPL_BMSL_avail_dschrg_10s_IA	);/*	10s内最大放电电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_CHRG_10S_PKW	,	&APPL_BMSL_avail_chrg_10s_PKW	);/*	10s内最大充电功率	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_CHRG_10S_IA	,	&APPL_BMSL_avail_chrg_10s_IA	);/*	10s内最大充电电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_DSCHRG_60S_PKW	,	&APPL_BMSL_avail_dschrg_60s_PKW	);/*	60s内最大放电功率	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_DSCHRG_60S_IA	,	&APPL_BMSL_avail_dschrg_60s_IA	);/*	60s内最大放电电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_CHRG_60S_PKW	,	&APPL_BMSL_avail_chrg_60s_PKW	);/*	60s内最大充电功率	*/
//	Com_SendSignal(	COM_TXSIGBMSL_AVAIL_CHRG_60S_IA	,	&APPL_BMSL_avail_chrg_60s_IA	);/*	60s内最大充电电流	*/
//	Com_SendSignal(	COM_TXSIGBMSL_CB_LIFETIME_REMAIN_PCT	,	&APPL_BMSL_cb_lifetime_remain_Pct	);/*	电池包继电器剩余寿命	*/
}



unsigned char crc_high_first(unsigned char *ptr, unsigned char len)
{
    unsigned char i;
    unsigned char crc=0xFF; /* 计算的初始crc值 */

    while(len--)
    {
        crc ^= *ptr++;  /* 每次先与需要计算的数据异或,计算完指向下一数据 */
        for (i=8; i>0; --i)   /* 下面这段计算过程与计算一个字节crc一样 */
        {
            if (crc & 0x80)
                crc = (crc << 1) ^ 0x2F;
            else
                crc = (crc << 1);
        }
    }
    crc=crc^ 0xFF;
    return (crc);
}

/********************************
**函数：	APPL_BMS_FanContrl
**功能：	根据应用层指令控制风扇
**输入：	无
**输出：	无
**注意：	风扇的占空精度为1%
*********************************/
void APPL_BMS_FanContrl(void)
{
	ECU_PWM_Update(ASW_FanContrl_PWM);
}
u8 FAN_FAULT_Time50;
void APPL_FAN_FAULT_CHECK(void)
{
	if(BSW_Ign_State)
	{
		if(BSW_GPIO_ReadBit(PTE,8))
		{
			if(FAN_FAULT_Time50 <= 60)
			{
				FAN_FAULT_Time50 ++;
			}
			else
			{
				Diag_FAN_Fault_Flg = 1;
			}
		}
		else
		{
			Diag_FAN_Fault_Flg = 0;
			FAN_FAULT_Time50 = 0;
		}
	}
	else
	{
		Diag_FAN_Fault_Flg = 0;
	}
}
extern u8 	FAN_DRVFAULT_Flg;
void APPL_FAN_DRVFAULT_CHECK(void)
{
	FANtest = FAN_DRVFAULT_Flg;
	if(ASW_FanContrl_PWM > 0 && ASW_FanContrl_PWM < 100)
	{
		Diag_FAN_HWDrvFlt_Flg = ECU_FAN_DRVFAULT_CHECK();
	}
	else
	{
		Diag_FAN_HWDrvFlt_Flg = 0;
	}
	BMSL_FANCotrolHWDrvFault_Status = Diag_FAN_HWDrvFlt_Flg;
}

void APPL_BMS_MC33771_BLANCE(void)
{
	if(!ASW_SleepCmd)
	{
		G_u16_Asw_CellFlg = ECU_EEPROM_CMB_CELL();
		APPL_MC33771_BLANCE(G_u16_Asw_CellFlg);
	}
}





